package com.chen.bpsptsystem.controller.front;

import com.chen.bpsptsystem.common.ServerResponse;
import com.chen.bpsptsystem.service.IClazzService;
import com.chen.bpsptsystem.service.IMaterialService;
import com.chen.bpsptsystem.service.IUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 前端用户
 *
 * @author chen
 */
@RestController
@RequestMapping("/front/user/")
public class FrontUserController {

    @Resource
    private IUserService userService;
    @Resource
    private IMaterialService materialService;

    @Resource
    private IClazzService clazzService;

    /**
     * 我的学习资料list
     *
     * @param pn
     * @param pageSize
     * @param userId
     * @return
     */
    @GetMapping("myMaterialList")
    public ServerResponse myMaterialList(@RequestParam(name = "pn", defaultValue = "1", value = "pn") Integer pn,
                                         @RequestParam(name = "pageSize", value = "pageSize", defaultValue = "10") Integer pageSize,
                                         Integer userId) {
        return userService.myMaterialList(pn, pageSize, userId);
    }

    /**
     * 资料详情
     *
     * @param mId
     * @return
     */
    @GetMapping("materialDetail")
    public ServerResponse materialDetail(Integer mId, Integer userId) {
        return materialService.findById(mId, userId);
    }

    /**
     * 评价学习资料
     *
     * @param userId
     * @param mId
     * @param note
     * @return
     */
    @PostMapping("evaluation")
    public ServerResponse evaluation(Integer userId, Integer mId, String note) {
        return materialService.evaluation(userId,mId,note);
    }

    /**
     * 资料的评价中心
     *
     * @param mId
     * @param pn
     * @param pageSize
     * @return
     */
    @GetMapping("evaluationList")
    public ServerResponse evaluationList(Integer mId,
                                         @RequestParam(name = "pn", defaultValue = "1", value = "pn") Integer pn,
                                         @RequestParam(name = "pageSize", value = "pageSize", defaultValue = "10") Integer pageSize) {
        return materialService.evaluationList(mId, pn, pageSize);
    }

    /**
     * 我的兴趣班
     *
     * @param userId
     * @return
     */
    @GetMapping("myInteClass")
    public ServerResponse myInteClass(Integer userId) {
        return materialService.myInteClass(userId);
    }


    //加一个班级详情
    //返回班级的属性和班级的资料
    @GetMapping("clazzDetail")
    public ServerResponse clazzDetail(Integer id){
        return clazzService.clazzDetail(id);
    }

    /**
     * 点赞
     * @return
     */
//    @PostMapping("doStar")
//    public ServerResponse doStar(){
//
//    }

}
